package com.example.myproject.model;

import java.time.Instant; // 确保导入 Instant

public class ChatMessage {
    private Long id;
    private String from;
    private String to;
    private String content;
    private MessageType type;
    private Instant timestamp; // 统一为 Instant
    private String readStatus; // 前端接收时为String，因为可能来自不同枚举

    public enum MessageType {
        CHAT,
        JOIN,
        LEAVE,
        SYSTEM,
        READ_RECEIPT // 添加READ_RECEIPT类型
    }

    // Getters and Setters
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public String getTo() {
        return to;
    }

    public void setTo(String to) {
        this.to = to;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public MessageType getType() {
        return type;
    }

    public void setType(MessageType type) {
        this.type = type;
    }

    public Instant getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Instant timestamp) {
        this.timestamp = timestamp;
    }

    public String getReadStatus() {
        return readStatus;
    }

    public void setReadStatus(String readStatus) {
        this.readStatus = readStatus;
    }

    @Override
    public String toString() {
        return "ChatMessage{" +
                "id=" + id +
                ", from='" + from + '\'' +
                ", to='" + to + '\'' +
                ", content='" + content + '\'' +
                ", type=" + type +
                ", timestamp=" + timestamp +
                ", readStatus='" + readStatus + '\'' +
                '}';
    }
}